public class test {
    public static void main(String[] args) {
        int count = 0;
        for (int i = 1000; i <2030 ; i++) {
            if(is_leap(i)){
                count++;
                System.out.print(i+" ");
                if(count%8==0&&count!=0){
                    System.out.println();
                }
            }
        }
        System.out.println(count);
    }
    public static boolean is_leap(int year){
        if(((year%4==0)&&(year%100!=0)) || (year%400==0))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
